flowbox: Update accessible state for children
authorMatthias Clasen <mclasen@redhat.com>
Tue, 13 Oct 2020 21:22:50 +0000 (17:22 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 13 Oct 2020 21:24:06 +0000 (17:24 -0400)
Set the SELECTED state to reflect whether the selected
is selected, unselected, or unselectable. This is
enough to make selection changes appear in Accerciser.

While we are at it, also set the multi-selectable
property for the flowbox itself.

gtk/gtkflowbox.c

index 7a306a8dc3ee8d8630a030e73594213d8072eac1..f7f60c9bcb3fef6b1a890d9479d04e7fe2b17eee 100644 (file)
@@ -75,6 +75,7 @@
 
 #include "gtkflowboxprivate.h"
 
+#include "gtkaccessible.h"
 #include "gtkadjustment.h"
 #include "gtkbinlayout.h"
 #include "gtkbuildable.h"
@@ -483,6 +484,18 @@ gtk_flow_box_child_compute_expand (GtkWidget *widget,
     }
 }
 
+static void
+gtk_flow_box_child_root (GtkWidget *widget)
+{
+  GtkFlowBoxChild *child = GTK_FLOW_BOX_CHILD (widget);
+
+  GTK_WIDGET_CLASS (gtk_flow_box_child_parent_class)->root (widget);
+
+  gtk_accessible_update_state (GTK_ACCESSIBLE (child),
+                               GTK_ACCESSIBLE_STATE_SELECTED, CHILD_PRIV (child)->selected,
+                               -1);
+}
+
 /* GObject implementation {{{2 */
 
 static void
@@ -495,6 +508,7 @@ gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class)
   object_class->get_property = gtk_flow_box_child_get_property;
   object_class->set_property = gtk_flow_box_child_set_property;
 
+  widget_class->root = gtk_flow_box_child_root;
   widget_class->get_request_mode = gtk_flow_box_child_get_request_mode;
   widget_class->compute_expand = gtk_flow_box_child_compute_expand;
   widget_class->focus = gtk_flow_box_child_focus;
@@ -905,6 +919,9 @@ gtk_flow_box_child_set_selected (GtkFlowBoxChild *child,
         gtk_widget_unset_state_flags (GTK_WIDGET (child),
                                       GTK_STATE_FLAG_SELECTED);
 
+      gtk_accessible_update_state (GTK_ACCESSIBLE (child),
+                                   GTK_ACCESSIBLE_STATE_SELECTED, selected,
+                                   -1);
       return TRUE;
     }
 
@@ -4724,6 +4741,10 @@ gtk_flow_box_set_selection_mode (GtkFlowBox       *box,
 
   BOX_PRIV (box)->selection_mode = mode;
 
+  gtk_accessible_update_property (GTK_ACCESSIBLE (box),
+                                  GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, mode == GTK_SELECTION_MULTIPLE,
+                                  -1);
+
   g_object_notify_by_pspec (G_OBJECT (box), props[PROP_SELECTION_MODE]);
 
   if (dirty)